import Vue from 'vue'
import Vuex from 'vuex'
import {getToken} from "../utils/auth";

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        // 这里放全局参数
        token: getToken(),
        user: {
            name: '',
            nickName: '',
            phone: '',
        }
    },
    mutations: {
        // 这里是set方法
        setToken: (state, token) => {
            state.token = token;
        },
        setUser: (state, user) => {
            state.user = user;
        }
    },
    getters: {
        // 这里是get方法
        getToken: state => state.token,
        getUser: state => state.user
    },
    actions: {},
    modules: {}
})
